import { CommonModal } from '@/pages/OrderModule/common/components/CommonModal';
import { Form, Radio } from 'antd';
import React, { useState } from 'react';
import { fieldMap } from '../../fieldMap';

/**
 * @description 选择一条售后订单
 */
const SelectOneOrderModal = React.memo((props) => {
	const {
    children,
    modalProps,
    onCancel,
    onChange,
    orderList,
		...arg
	} = props;

  const [ form ] = Form.useForm();

  function handleSubmit (value) {
    form.validateFields().then(val => {
      onChange && onChange(val?.k2)
    })
  }

  return (
    <CommonModal
      title={{title: "提示"}}
      {...modalProps}
      open={true}
      width={396}
      onOk={handleSubmit}
      onCancel={onCancel}
    >
      <Form
        form={form}
      >
        <p>请选择该商品属于那个售后单中</p>
        <Form.Item name="k2" style={{marginTop: 10}}>
          <Radio.Group>
            {
              orderList.map(item => {
                const val = item[fieldMap['售后单号']]
                return <div key={val} style={{marginTop: 8}}><Radio value={val}>售后单号：{val}</Radio></div>
              })
            }
          </Radio.Group>
        </Form.Item>
      </Form>
      {/* <CommonLoading loading={loading} /> */}
    </CommonModal>
  );
});
export default SelectOneOrderModal;
